"use strict";
var license = require("../utils/license");
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("div", { ref: "root", staticClass: "ele-avatar-list" }, [_vm._l(_vm.avatarList, function(item, index2) {
    return [_vm.tooltip && item[_vm.name] ? [_c("el-tooltip", { key: _vm.itemKey && item[_vm.itemKey] ? item[_vm.itemKey] : index2, attrs: { "content": item[_vm.name], "placement": _vm.placement, "effect": _vm.effect, "offset": _vm.offset, "transition": _vm.transition } }, [_c("el-avatar", { key: _vm.itemKey && item[_vm.itemKey] ? item[_vm.itemKey] : index2, style: [_vm.commonStyle, _vm.itemStyle, _vm.avatarStyle], attrs: { "size": _vm.size, "shape": _vm.shape, "alt": item[_vm.name], "src": item[_vm.avatar] }, on: { "click": function($event) {
      return _vm.onItemClick(item);
    } } })], 1)] : [_c("el-avatar", { key: _vm.itemKey && item[_vm.itemKey] ? item[_vm.itemKey] : index2, style: [_vm.commonStyle, _vm.itemStyle, _vm.avatarStyle], attrs: { "size": _vm.size, "shape": _vm.shape, "alt": item[_vm.name], "src": item[_vm.avatar] }, on: { "click": function($event) {
      return _vm.onItemClick(item);
    } } })]];
  }), _vm.isOverflow ? _c("el-avatar", { staticClass: "ele-avatar-list-more", style: [_vm.commonStyle, _vm.itemStyle, _vm.moreStyle], attrs: { "size": _vm.size, "shape": _vm.shape }, on: { "click": _vm.onMoreClick } }, [_vm._v(" " + _vm._s(_vm.moreText) + " ")]) : _vm._e()], 2);
};
var staticRenderFns = [];
function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
  var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
  if (render2) {
    options.render = render2;
    options.staticRenderFns = staticRenderFns2;
    options._compiled = true;
  }
  if (functionalTemplate) {
    options.functional = true;
  }
  if (scopeId) {
    options._scopeId = "data-v-" + scopeId;
  }
  var hook;
  if (moduleIdentifier) {
    hook = function(context) {
      context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
      if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
        context = __VUE_SSR_CONTEXT__;
      }
      if (injectStyles) {
        injectStyles.call(this, context);
      }
      if (context && context._registeredComponents) {
        context._registeredComponents.add(moduleIdentifier);
      }
    };
    options._ssrRegister = hook;
  } else if (injectStyles) {
    hook = shadowMode ? function() {
      injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
    } : injectStyles;
  }
  if (hook) {
    if (options.functional) {
      options._injectStyles = hook;
      var originalRender = options.render;
      options.render = function renderWithStyleInjection(h, context) {
        hook.call(context);
        return originalRender(h, context);
      };
    } else {
      var existing = options.beforeCreate;
      options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
    }
  }
  return {
    exports: scriptExports,
    options
  };
}
const __vue2_script = {
  name: "EleAvatarList",
  props: {
    data: {
      type: Array,
      required: true
    },
    max: {
      type: Number,
      default: 0
    },
    name: {
      type: String,
      default: "name"
    },
    avatar: {
      type: String,
      default: "avatar"
    },
    itemKey: String,
    shape: {
      type: String,
      default: "circle",
      validator: (value) => {
        return ["circle", "square"].includes(value);
      }
    },
    size: {
      type: [Number, String],
      default: "medium",
      validator: (value) => {
        if (typeof value === "string") {
          return ["large", "medium", "small"].includes(value);
        } else {
          return value > 0;
        }
      }
    },
    itemStyle: [String, Object],
    avatarStyle: [String, Object],
    moreStyle: [String, Object],
    tooltip: {
      type: Boolean,
      default: true
    },
    placement: {
      type: String,
      default: "top"
    },
    effect: {
      type: String,
      default: "dark"
    },
    offset: {
      type: Number,
      default: 0
    },
    transition: {
      type: String,
      default: "el-fade-in-linear"
    }
  },
  emits: ["item-click", "more-click"],
  data() {
    return {
      authenticated: license.checkLicense()
    };
  },
  computed: {
    commonStyle() {
      if (typeof this.size === "number") {
        return { marginLeft: `${-Math.round(this.size / 3)}px` };
      } else if (typeof this.size === "string") {
        return {
          marginLeft: {
            large: "-12px",
            medium: "-10px",
            small: "-8px"
          }[this.size] || "-12px"
        };
      }
      return {};
    },
    avatarList() {
      if (!this.authenticated) {
        return [];
      }
      if (!this.max || !this.data || this.data.length <= this.max) {
        return this.data;
      }
      return this.data.slice(0, this.max);
    },
    isOverflow() {
      return this.max && this.data && this.data.length > this.max;
    },
    moreText() {
      var _a, _b;
      return `+${((_b = (_a = this.data) == null ? void 0 : _a.length) != null ? _b : 0) - this.max}`;
    }
  },
  methods: {
    onItemClick(item) {
      this.$emit("item-click", item);
    },
    onMoreClick() {
      this.$emit("more-click");
    }
  }
};
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var index = /* @__PURE__ */ function() {
  return __component__.exports;
}();
module.exports = index;
